%%% Copyright 2010 Google Inc.
%%%
%%% Licensed under the Apache License, Version 2.0 (the "License");
%%% you may not use this file except in compliance with the License.
%%% You may obtain a copy of the License at
%%%
%%%     http://www.apache.org/licenses/LICENSE-2.0
%%%
%%% Unless required by applicable law or agreed to in writing, software
%%% distributed under the License is distributed on an "AS IS" BASIS,
%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%%% See the License for the specific language governing permissions and
%%% limitations under the License.

%%% Author jacoby@google.com (Jacoby Thwaites)
%%% Header file for the txml: module for program source processing.

%%% ---------------------------------------------------------------------------
%%% XML namespace URI
%%% ---------------------------------------------------------------------------
-define(TXML_NS, "http://madcloud.googlecode.com/v1").

%%% ---------------------------------------------------------------------------
%%% XML element and attribute names as strings.
%%% ---------------------------------------------------------------------------

-define(ELEMENT_LIST, "list").
-define(ELEMENT_FOLDER, "folder").
-define(ELEMENT_FIELD, "field").
-define(ELEMENT_MASK, "mask").
-define(ELEMENT_OP, "op").
-define(ELEMENT_INPUT, "input").
-define(ELEMENT_OUTPUT, "output").

-define(ATTR_NAME, "name").
-define(ATTR_TYPE, "type").
-define(ATTR_FIELDS, "fields").

%% Special value to indicate an attribute has no default value.
-define(ATTR_NO_DEFAULT, "no_default").

%%% ---------------------------------------------------------------------------
%%% SAX parser records in ALPHA ORDER. These are atoms or tuples for which
%%% defining records makes it more readable.
%%% ---------------------------------------------------------------------------

-define(COMMENT, comment).
-record(?COMMENT, {comment :: string()}).

-define(END_DOCUMENT, endDocument).

-define(END_ELEMENT, endElement).
-record(?END_ELEMENT, {uri :: string(),
             lname :: string(),
             qname :: {string(), string()}}).

-define(END_PREFIX_MAPPING, endPrefixMapping).
-record(?END_PREFIX_MAPPING, {prefix :: string()}).

-define(IGNORABLE_WHITESPACE, ignorableWhitespace).
-record(?IGNORABLE_WHITESPACE, {whitespace :: string()}).

-define(START_DOCUMENT, startDocument).

-define(START_ELEMENT, startElement).
-record(?START_ELEMENT, {uri :: string(),
                         lname :: string(),
                         qname :: {string(), string()},
                         attributes :: list()}).

-define(START_PREFIX_MAPPING, startPrefixMapping).
-record(?START_PREFIX_MAPPING, {prefix :: string(),
                                uri :: string()}).

%%% ---------------------------------------------------------------------------
%%% Event state record used to pass the stack of entities under construction
%%% (being the name and record) and the stack of folders.
%%% ---------------------------------------------------------------------------

-type(entity() :: {string(), #op{} | #folder{} | #field{}}).
-type(stack() :: list(entity())).
